package no.ntnu.fp.mmi;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextPane;
import javax.swing.WindowConstants;

import no.ntnu.fp.su.Message;


@SuppressWarnings("serial")
public class ViewMessagePanel extends javax.swing.JFrame {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	
	private JLabel messageLabel;
	private JButton closeButton;
	private JTextPane commentPane;
	Font font = new Font("Candera", Font.BOLD, 17);
	private Message message;
	
	
	/**
	* Constructor for viewMessagePanel
	* 
	* @param Message that contains the message
	*/
	
	public ViewMessagePanel(Message melding) {
		super();
		this.message = melding;
		this.setVisible(true);
		this.setTitle("Message");
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				messageLabel = new JLabel();
				getContentPane().add(messageLabel);
				messageLabel.setText("Message from: " + message.getFrom().getName() );
				messageLabel.setFont(font);
				messageLabel.setBounds(162, 24, 176, 26);
			}
			{
				commentPane = new JTextPane();
				getContentPane().add(commentPane);
				commentPane.setText("");
				commentPane.setBounds(156, 62, 164, 219);
				commentPane.setEditable(false);
				commentPane.setText(message.getText());
		
			}
			{
				closeButton = new JButton();
				getContentPane().add(closeButton);
				closeButton.setText("Close");
				closeButton.setBounds(189, 303, 88, 23);
				closeButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						dispose();
					}
				});
			}

			setSize(500, 400);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
